package com.pw.manage.education.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.pw.domain.EmployeesBaseInfo;
import com.pw.manage.education.domain.vo.EmployeesEducationVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pw.common.annotation.Log;
import com.pw.common.core.controller.BaseController;
import com.pw.common.core.domain.AjaxResult;
import com.pw.common.enums.BusinessType;
import com.pw.manage.education.service.IEmployeesEducationService;
import com.pw.common.utils.poi.ExcelUtil;
import com.pw.common.core.page.TableDataInfo;

/**
 * 员工基本信息Controller
 *
 * @author lye
 * @date 2024-12-28
 */
@RestController
@RequestMapping("/manage/education")
public class EmployeesEducationController extends BaseController
{
    @Autowired
    private IEmployeesEducationService employeesBaseInfoService;

    /**
     * 查询员工基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:education:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmployeesBaseInfo employeesBaseInfo)
    {
        startPage();
        List<EmployeesBaseInfo> list = employeesBaseInfoService.selectEmployeesBaseInfoList(employeesBaseInfo);
        return getDataTable(list);
    }

    /**
     * 查询员工基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:education:list')")
    @GetMapping("/listInfo")
    public TableDataInfo EducationList(EmployeesBaseInfo employeesBaseInfo)
    {
        startPage();
        List<EmployeesEducationVo> list = employeesBaseInfoService.selectEmployeesEducationList(employeesBaseInfo);
        return getDataTable(list);
    }

    /**
     * 导出员工基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:education:export')")
    @Log(title = "员工基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmployeesBaseInfo employeesBaseInfo)
    {
        List<EmployeesBaseInfo> list = employeesBaseInfoService.selectEmployeesBaseInfoList(employeesBaseInfo);
        ExcelUtil<EmployeesBaseInfo> util = new ExcelUtil<EmployeesBaseInfo>(EmployeesBaseInfo.class);
        util.exportExcel(response, list, "员工基本信息数据");
    }

    /**
     * 获取员工基本信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:education:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(employeesBaseInfoService.selectEmployeesBaseInfoById(id));
    }

    /**
     * 新增员工基本信息
     */
    @PreAuthorize("@ss.hasPermi('manage:education:add')")
    @Log(title = "员工基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmployeesBaseInfo employeesBaseInfo)
    {
        return toAjax(employeesBaseInfoService.insertEmployeesBaseInfo(employeesBaseInfo));
    }

    /**
     * 修改员工基本信息
     */
    @PreAuthorize("@ss.hasPermi('manage:education:edit')")
    @Log(title = "员工基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmployeesBaseInfo employeesBaseInfo)
    {
        return toAjax(employeesBaseInfoService.updateEmployeesBaseInfo(employeesBaseInfo));
    }

    /**
     * 删除员工基本信息
     */
    @PreAuthorize("@ss.hasPermi('manage:education:remove')")
    @Log(title = "员工基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(employeesBaseInfoService.deleteEmployeesBaseInfoByIds(ids));
    }
}
